package resoft.jeasyform.event;

import resoft.jeasyform.components.Window;
import resoft.jeasyform.components.Component;
import resoft.jeasyform.components.InputField;

/**
 * <p>prevent empty</p>
 * User: albert
 * Date: Aug 27, 2007
 * Time: 3:31:10 AM
 */
public class PreventEmptyEventHandler implements EventHandler{
    public boolean execute(Window window, Component source, int eventType) {
        if(source instanceof InputField) {
            String value = ((InputField)source).getValue();
            if(value==null || value.equals("")) {
                String msg = window.getProperty("EmptyMessage");
                if(!msg.equals("")) {
                    window.setMessage(msg);
                }
                return false;
            }
        }
        return true;
    }
}
